package admin

import (
	. "go-caipu/pkg/services/sqlstore/migrator"
)

func AddLoginLogMigrations(mg *Migrator) {
	userV1 := Table{
		Name: "sys_login_log",
		Columns: []*Column{
			{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "username", Type: DB_Varchar, Length: 128, Nullable: true},
			{Name: "status", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "ipaddr", Type: DB_NVarchar, Length: 32, Nullable: true},
			{Name: "login_location", Type: DB_NVarchar, Length: 128, Nullable: true},
			{Name: "browser", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "os", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "platform", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "login_time", Type: DB_DateTime, Length: 6, Nullable: true},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},
			{Name: "msg", Type: DB_NVarchar, Length: 255, Nullable: true},

			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"username"}, Type: UniqueIndex},
		},
	}
	//create table
	mg.AddMigration("create sys_login_log table", NewAddTableMigration(userV1))
}
